<!DOCTYPE html>
<!--suppress JSAnnotator -->
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../../js/jquery.mini.js"></script>
</head>
<body>


<button onclick="testData()">点击</button>
</body>

<script>


    //删除
    //    var removed = lang.splice(1,1);
    //    alert(lang); //php,javascript
    //    alert(removed); //java ,返回删除的项
    //插入
    //    var insert = lang.splice(0,0,"asp"); //从第0个位置开始插入
    //    alert(insert); //返回空数组
    //    alert(lang); //asp,php,javascript
    //替换
    //    var replace = lang.splice(1,1,"c#","ruby"); //删除一项，插入两项
    //    alert(lang); //asp,c#,ruby
    //    alert(replace); //php,返回删除的项
    //    var split = lang.split(',');

    //
    //
    //    function doTest() {
    //        var lang = ["php","java","javascript"];
    //        var position =lang.split(',')
    //        for (var i in position) {
    //            if (position.hasOwnProperty(i)) {
    ////            this.prizeList[indexs[i]].imgUrl = this.winPrize[i].imgUrl
    ////            this.prizeList[indexs[i]].name = this.winPrize[i].name
    //                console.log('=consumePoint==' + position)
    //            }
    //        }
    //
    //    }


    var prizeDatax = '{\n' +
        '    "errorCode": 0,\n' +
        '    "message": "请求成功",\n' +
        '    "data": [\n' +
        '        {\n' +
        '            "id": 1830,\n' +
        '            "platform": null,\n' +
        '            "status": 1,\n' +
        '            "type": 201,\n' +
        '            "info": "1元观影券",\n' +
        '            "name": "1元观影券",\n' +
        '            "openId": "18907447909",\n' +
        '            "price": 59,\n' +
        '            "version": "whiteList",\n' +
        '            "createdTime": 1519869734000,\n' +
        '            "disabledTime": 1522511995000,\n' +
        '            "usedTime": null,\n' +
        '            "tails": {}\n' +
        '        },\n' +
        '        {\n' +
        '            "id": 1832,\n' +
        '            "platform": null,\n' +
        '            "status": 1,\n' +
        '            "type": 201,\n' +
        '            "info": "1元观影券",\n' +
        '            "name": "1元观影券",\n' +
        '            "openId": "18907447909",\n' +
        '            "price": 59,\n' +
        '            "version": "whiteList",\n' +
        '            "createdTime": 1519869734000,\n' +
        '            "disabledTime": 1522511995000,\n' +
        '            "usedTime": null,\n' +
        '            "tails": {}\n' +
        '        },\n' +
        '        {\n' +
        '            "id": 1838,\n' +
        '            "platform": null,\n' +
        '            "status": 1,\n' +
        '            "type": 210,\n' +
        '            "info": "10元观影券",\n' +
        '            "name": "10元观影券",\n' +
        '            "openId": "18907447909",\n' +
        '            "price": 50,\n' +
        '            "version": "sendHand",\n' +
        '            "createdTime": 1519871533000,\n' +
        '            "disabledTime": 1522512000000,\n' +
        '            "usedTime": null,\n' +
        '            "tails": {}\n' +
        '        },\n' +
        '        {\n' +
        '            "id": 1859,\n' +
        '            "platform": null,\n' +
        '            "status": 1,\n' +
        '            "type": 201,\n' +
        '            "info": "1元观影券",\n' +
        '            "name": "1元观影券",\n' +
        '            "openId": "18907447909",\n' +
        '            "price": 59,\n' +
        '            "version": "sendHand",\n' +
        '            "createdTime": 1519895858000,\n' +
        '            "disabledTime": 1522511999000,\n' +
        '            "usedTime": null,\n' +
        '            "tails": {}\n' +
        '        },\n' +
        '        {\n' +
        '            "id": 1860,\n' +
        '            "platform": null,\n' +
        '            "status": 1,\n' +
        '            "type": 200,\n' +
        '            "info": "免费观影券",\n' +
        '            "name": "免费观影券",\n' +
        '            "openId": "18907447909",\n' +
        '            "price": 60,\n' +
        '            "version": "sendHand",\n' +
        '            "createdTime": 1519900853000,\n' +
        '            "disabledTime": 1522512000000,\n' +
        '            "usedTime": null,\n' +
        '            "tails": {}\n' +
        '        },\n' +
        '        {\n' +
        '            "id": 1827,\n' +
        '            "platform": null,\n' +
        '            "status": 1,\n' +
        '            "type": 305,\n' +
        '            "info": "5元抵用券",\n' +
        '            "name": "5元抵用券",\n' +
        '            "openId": "18907447909",\n' +
        '            "price": 5,\n' +
        '            "version": "sendHand",\n' +
        '            "createdTime": 1519804924000,\n' +
        '            "disabledTime": 1522425600000,\n' +
        '            "usedTime": null,\n' +
        '            "tails": {}\n' +
        '        },\n' +
        '        {\n' +
        '            "id": 1839,\n' +
        '            "platform": null,\n' +
        '            "status": 1,\n' +
        '            "type": 310,\n' +
        '            "info": "10元抵用券",\n' +
        '            "name": "10元抵用券",\n' +
        '            "openId": "18907447909",\n' +
        '            "price": 10,\n' +
        '            "version": "sendHand",\n' +
        '            "createdTime": 1519871551000,\n' +
        '            "disabledTime": 1522511999000,\n' +
        '            "usedTime": null,\n' +
        '            "tails": {}\n' +
        '        },\n' +
        '        {\n' +
        '            "id": 1840,\n' +
        '            "platform": null,\n' +
        '            "status": 1,\n' +
        '            "type": 310,\n' +
        '            "info": "10元抵用券",\n' +
        '            "name": "10元抵用券",\n' +
        '            "openId": "18907447909",\n' +
        '            "price": 10,\n' +
        '            "version": "sendHand",\n' +
        '            "createdTime": 1519871615000,\n' +
        '            "disabledTime": 1522512000000,\n' +
        '            "usedTime": null,\n' +
        '            "tails": {}\n' +
        '        },\n' +
        '        {\n' +
        '            "id": 1852,\n' +
        '            "platform": null,\n' +
        '            "status": 1,\n' +
        '            "type": 305,\n' +
        '            "info": "5元抵用券",\n' +
        '            "name": "5元抵用券",\n' +
        '            "openId": "18907447909",\n' +
        '            "price": 5,\n' +
        '            "version": "sendHand",\n' +
        '            "createdTime": 1519892387000,\n' +
        '            "disabledTime": 1522512000000,\n' +
        '            "usedTime": null,\n' +
        '            "tails": {}\n' +
        '        },\n' +
        '        {\n' +
        '            "id": 1853,\n' +
        '            "platform": null,\n' +
        '            "status": 1,\n' +
        '            "type": 300,\n' +
        '            "info": "随机抵用券null元",\n' +
        '            "name": "随机抵用券null元",\n' +
        '            "openId": "18907447909",\n' +
        '            "price": 15,\n' +
        '            "version": "sendHand",\n' +
        '            "createdTime": 1519892462000,\n' +
        '            "disabledTime": 1522511999000,\n' +
        '            "usedTime": null,\n' +
        '            "tails": {}\n' +
        '        },\n' +
        '        {\n' +
        '            "id": 1857,\n' +
        '            "platform": null,\n' +
        '            "status": 1,\n' +
        '            "type": 300,\n' +
        '            "info": "25元随机抵用券",\n' +
        '            "name": "25元随机抵用券",\n' +
        '            "openId": "18907447909",\n' +
        '            "price": 25,\n' +
        '            "version": "sendHand",\n' +
        '            "createdTime": 1519894744000,\n' +
        '            "disabledTime": 1522512000000,\n' +
        '            "usedTime": null,\n' +
        '            "tails": {}\n' +
        '        }\n' +
        '    ]\n' +
        '}';


       var prizeData='{\n' +
           '    "errorCode": 0,\n' +
           '    "message": "请求成功",\n' +
           '    "data": [\n' +
           '        {\n' +
           '            "id": 1830,\n' +
           '            "platform": null,\n' +
           '            "status": 1,\n' +
           '            "type": 201,\n' +
           '            "info": "1元观影券",\n' +
           '            "name": "1元观影券",\n' +
           '            "openId": "18907447909",\n' +
           '            "price": 59,\n' +
           '            "version": "whiteList",\n' +
           '            "createdTime": 1519869734000,\n' +
           '            "disabledTime": 1522511995000,\n' +
           '            "usedTime": null,\n' +
           '            "tails": {}\n' +
           '        },\n' +
           '        {\n' +
           '            "id": 1832,\n' +
           '            "platform": null,\n' +
           '            "status": 1,\n' +
           '            "type": 201,\n' +
           '            "info": "1元观影券",\n' +
           '            "name": "1元观影券",\n' +
           '            "openId": "18907447909",\n' +
           '            "price": 59,\n' +
           '            "version": "whiteList",\n' +
           '            "createdTime": 1519869734000,\n' +
           '            "disabledTime": 1522511995000,\n' +
           '            "usedTime": null,\n' +
           '            "tails": {}\n' +
           '        },\n' +
           '        {\n' +
           '            "id": 1838,\n' +
           '            "platform": null,\n' +
           '            "status": 1,\n' +
           '            "type": 210,\n' +
           '            "info": "10元观影券",\n' +
           '            "name": "10元观影券",\n' +
           '            "openId": "18907447909",\n' +
           '            "price": 50,\n' +
           '            "version": "sendHand",\n' +
           '            "createdTime": 1519871533000,\n' +
           '            "disabledTime": 1522512000000,\n' +
           '            "usedTime": null,\n' +
           '            "tails": {}\n' +
           '        },\n' +
           '        {\n' +
           '            "id": 1859,\n' +
           '            "platform": null,\n' +
           '            "status": 1,\n' +
           '            "type": 201,\n' +
           '            "info": "1元观影券",\n' +
           '            "name": "1元观影券",\n' +
           '            "openId": "18907447909",\n' +
           '            "price": 59,\n' +
           '            "version": "sendHand",\n' +
           '            "createdTime": 1519895858000,\n' +
           '            "disabledTime": 1522511999000,\n' +
           '            "usedTime": null,\n' +
           '            "tails": {}\n' +
           '        },\n' +
           '        {\n' +
           '            "id": 1860,\n' +
           '            "platform": null,\n' +
           '            "status": 1,\n' +
           '            "type": 200,\n' +
           '            "info": "免费观影券",\n' +
           '            "name": "免费观影券",\n' +
           '            "openId": "18907447909",\n' +
           '            "price": 60,\n' +
           '            "version": "sendHand",\n' +
           '            "createdTime": 1519900853000,\n' +
           '            "disabledTime": 1522512000000,\n' +
           '            "usedTime": null,\n' +
           '            "tails": {}\n' +
           '        },\n' +
           '        {\n' +
           '            "id": 1862,\n' +
           '            "platform": null,\n' +
           '            "status": 1,\n' +
           '            "type": 200,\n' +
           '            "info": "免费观影券",\n' +
           '            "name": "免费观影券",\n' +
           '            "openId": "18907447909",\n' +
           '            "price": 60,\n' +
           '            "version": "sendHand",\n' +
           '            "createdTime": 1519971817000,\n' +
           '            "disabledTime": 1522598399000,\n' +
           '            "usedTime": null,\n' +
           '            "tails": {}\n' +
           '        },\n' +
           '        {\n' +
           '            "id": 1827,\n' +
           '            "platform": null,\n' +
           '            "status": 1,\n' +
           '            "type": 305,\n' +
           '            "info": "5元抵用券",\n' +
           '            "name": "5元抵用券",\n' +
           '            "openId": "18907447909",\n' +
           '            "price": 5,\n' +
           '            "version": "sendHand",\n' +
           '            "createdTime": 1519804924000,\n' +
           '            "disabledTime": 1522425600000,\n' +
           '            "usedTime": null,\n' +
           '            "tails": {}\n' +
           '        },\n' +
           '        {\n' +
           '            "id": 1839,\n' +
           '            "platform": null,\n' +
           '            "status": 1,\n' +
           '            "type": 310,\n' +
           '            "info": "10元抵用券",\n' +
           '            "name": "10元抵用券",\n' +
           '            "openId": "18907447909",\n' +
           '            "price": 10,\n' +
           '            "version": "sendHand",\n' +
           '            "createdTime": 1519871551000,\n' +
           '            "disabledTime": 1522511999000,\n' +
           '            "usedTime": null,\n' +
           '            "tails": {}\n' +
           '        },\n' +
           '        {\n' +
           '            "id": 1840,\n' +
           '            "platform": null,\n' +
           '            "status": 1,\n' +
           '            "type": 310,\n' +
           '            "info": "10元抵用券",\n' +
           '            "name": "10元抵用券",\n' +
           '            "openId": "18907447909",\n' +
           '            "price": 10,\n' +
           '            "version": "sendHand",\n' +
           '            "createdTime": 1519871615000,\n' +
           '            "disabledTime": 1522512000000,\n' +
           '            "usedTime": null,\n' +
           '            "tails": {}\n' +
           '        },\n' +
           '        {\n' +
           '            "id": 1852,\n' +
           '            "platform": null,\n' +
           '            "status": 1,\n' +
           '            "type": 305,\n' +
           '            "info": "5元抵用券",\n' +
           '            "name": "5元抵用券",\n' +
           '            "openId": "18907447909",\n' +
           '            "price": 5,\n' +
           '            "version": "sendHand",\n' +
           '            "createdTime": 1519892387000,\n' +
           '            "disabledTime": 1522512000000,\n' +
           '            "usedTime": null,\n' +
           '            "tails": {}\n' +
           '        },\n' +
           '        {\n' +
           '            "id": 1853,\n' +
           '            "platform": null,\n' +
           '            "status": 1,\n' +
           '            "type": 300,\n' +
           '            "info": "随机抵用券null元",\n' +
           '            "name": "随机抵用券null元",\n' +
           '            "openId": "18907447909",\n' +
           '            "price": 15,\n' +
           '            "version": "sendHand",\n' +
           '            "createdTime": 1519892462000,\n' +
           '            "disabledTime": 1522511999000,\n' +
           '            "usedTime": null,\n' +
           '            "tails": {}\n' +
           '        },\n' +
           '        {\n' +
           '            "id": 1857,\n' +
           '            "platform": null,\n' +
           '            "status": 1,\n' +
           '            "type": 300,\n' +
           '            "info": "25元随机抵用券",\n' +
           '            "name": "25元随机抵用券",\n' +
           '            "openId": "18907447909",\n' +
           '            "price": 25,\n' +
           '            "version": "sendHand",\n' +
           '            "createdTime": 1519894744000,\n' +
           '            "disabledTime": 1522512000000,\n' +
           '            "usedTime": null,\n' +
           '            "tails": {}\n' +
           '        },\n' +
           '        {\n' +
           '            "id": 1861,\n' +
           '            "platform": null,\n' +
           '            "status": 1,\n' +
           '            "type": 300,\n' +
           '            "info": "12元随机抵用券",\n' +
           '            "name": "12元随机抵用券",\n' +
           '            "openId": "18907447909",\n' +
           '            "price": 12,\n' +
           '            "version": "sendHand",\n' +
           '            "createdTime": 1519955387000,\n' +
           '            "disabledTime": 1522598399000,\n' +
           '            "usedTime": null,\n' +
           '            "tails": {}\n' +
           '        }\n' +
           '    ]\n' +
           '}';


//    var guanYingQuanTypeArray = [201, 210, 200]
//    var diYongQuanTypeArray = [300, 310, 305]
    function testData() {
        var prizeArray = JSON.parse(prizeData).data;
        var sortArray = prizeArray.sort(sortPrice);
        var type = sortArray[0].type;
        console.log(JSON.stringify(type))
        var originalArray = JSON.parse(prizeData).data;
        var of = indexOf(originalArray,type);
        console.log('==='+JSON.stringify(of));
    }
    function sortPrice(a,b){
        return b.price-a.price
    }


    function indexOf (arr, str) {
        let number = 0
        arr.forEach(function (item, index) {
//            console.log('===' +JSON.stringify(item.type))
//            console.log('==xxxx=' +JSON.stringify(str))
            if (str === item.type) {
                number = index
            }
        })
        return number
    }

    function dateStringFromDate(timeInterval) {
        // yyyy-MM-dd hh:mm:ss
        var format = 'yyyy-MM-dd hh:mm:ss';
        var date = new Date(timeInterval);
        var paddNum = function (num) {
            num += '';
            return num.replace(/^(\d)$/, '0$1');
        };
        // 指定格式字符
        var cfg = {
            yyyy: date.getFullYear(), // 年 : 4位
            yy: date.getFullYear().toString().substring(2), // 年 : 2位
            M: date.getMonth() + 1, // 月 : 如果1位的时候不补0
            MM: paddNum(date.getMonth() + 1), // 月 : 如果1位的时候补0
            d: date.getDate(), // 日 : 如果1位的时候不补0
            dd: paddNum(date.getDate()), // 日 : 如果1位的时候补0
            hh: date.getHours(), // 时
            mm: paddNum(date.getMinutes()), // 分
            ss: paddNum(date.getSeconds()) // 秒
        };
        format || (format = 'yyyy-MM-dd hh:mm:ss');
        return format.replace(/([a-z])(\1)*/ig, function (m) {
            return cfg[m];
        });
    }




    //        console.log('===' + JSON.stringify(parseArray.length))
    //        window.alert(parseArray[0].createdTime)
    //        console.log(dateStringFromDate(parseArray[0].createdTime))
//    prizeArray.forEach(function (prizeItem, prizeIndex) {
//            console.log("遍历" + prizeArray[index] + "-----" + item);
//            if (guanYingQuanTypeArray.contains(prizeArray[prizeIndex])) {
//               window.alert('==='+index)
//            }
//
//    });
    //        guanYingQuanTypeArray.forEach(function (typeItem, typeIndex) {
    //            window.alert("遍历" + guanYingQuanTypeArray[typeIndex] + "-----" + typeItem);
    //        })
</script>
</html>